<template>
	<view class="step-body">
		<view class="purchase-module">
			<view class="purchase-title">
				所属项目信息
			</view>
			<view class="purchase-content">
				<view class="content-box">
					<view class="cbox-1">
						项目建设类别
					</view>
					<view class="cbox-2">
						{{projectcategory}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						项目名称
					</view>
					<view class="cbox-2">
						{{projectname}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						经费管理部门<br>负责人
					</view>
					<view class="cbox-2">
						{{realnamelist}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						子项目名称
					</view>
					<view class="cbox-2">
						{{subprojectname}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						子项目负责人
					</view>
					<view class="cbox-2">
						{{zxmuser}}
					</view>
				</view>
			
			</view>
		</view>
		<view class="purchase-module">
			<view class="purchase-title">
				申请信息
			</view>
			<view class="purchase-content">
				<view class="content-box">
					<view class="cbox-1">
						申请名称
					</view>
					<view class="cbox-2">
						{{purName}}
					</view>
				</view>
				<view class="content-qbox">
					<view class="qbox-1">
						产品清单
					</view>
					<view class="qbox-2" v-for="item in productList" :key='item.id'>
						<view class="rbox-1">
							<view class="rbox-title">
								{{item.prodInventName}}
							</view>
							<view class="rbox-item">
                             <text>单价(元)：</text>
							 <text>{{item.unitPrice?item.unitPrice.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','):'--'}}</text>
							 
							</view>
							<view class="rbox-item">
							 <text>数量：</text>
							 <text>{{item.amount}}</text>
							 
							</view>
							<view class="rbox-item">
							 <text>金额(元)：</text>
							 <text>{{item.money?item.money.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','):'--'}}</text>
							 
							</view>
							<view class="rbox-item">
							 <text>采购品目：</text>
							 <text>{{item.purchaseItem_dictText}}</text>
							 
							</view>

						</view>
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						经费预算(元)
					</view>
					<view class="cbox-2">
						{{purchaseMoney}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						申请部门
					</view>
					<view class="cbox-2">
						{{deptName}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
                    经办人
					</view>
					<view class="cbox-2">
					{{realname}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						联系方式
					</view>
					<view class="cbox-2">
						{{phoneNumber}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
					   申请人
					</view>
					<view class="cbox-2">
						{{applyUserId_dictText}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
					   申请理由
					</view>
					<view class="cbox-2">
						{{applyReason}}
					</view>
				</view>
				
				<view class="content-box">
					<view class="cbox-1">
						是否政府集中<br>
						采购目录内产品
					</view>
					<view class="cbox-2">
				        {{isGovPruchase=='1'?'目录内':'目录外'}}
					</view>
				</view>
				<view class="content-box" >
					<view class="cbox-1">
					 采购方式
					</view>
					<view class="cbox-2">
						{{purWays}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						采购种类
					</view>
					<view class="cbox-2">
						{{cgType}}
					</view>
				</view>
				
				<view class="content-box">
					<view class="cbox-1">
						采购用途
					</view>
					<view class="cbox-2">
						{{equipmentUsed}}
					</view>
				</view>
				<!-- <view class="content-box">
					<view class="cbox-1">
						预算类别
					</view>
					<view class="cbox-2">
						{{purCategory}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						预算类别附属<br>信息
					</view>
					<view class="cbox-2">
						{{purCategoryAttach}}
					</view>
				</view> -->
					<view class="content-box">
					<view class="cbox-1">
						交货期(月)
					</view>
					<view class="cbox-2">
						{{deliveryDate}}
					</view>
				</view>	<view class="content-box">
					<view class="cbox-1">
						质保期(年)
					</view>
					<view class="cbox-2">
					{{guaranteePeriod}}
					</view>
				</view>	
				<view class="content-box" v-if="flagePurchase">
					<view class="cbox-1">
						计划开始时间
					</view>
					<view class="cbox-2">
						{{planStartTime}}
					</view>
				</view>
				<view class="content-box" v-if="flagePurchase">
					<view class="cbox-1">
						采购内容
					</view>
					<view class="cbox-2">
						{{purContent}}
					</view>
				</view>
				<view class="content-box" v-if="flagePurchase">
					<view class="cbox-1">
						项目概况
					</view>
					<view class="cbox-2">
						{{projectSurvey}}
					</view>
				</view>
			
				<view class="content-box">
					<view class="cbox-1">
						是否信息化处项目
					</view>
					<view class="cbox-2">
						{{whetherTheInformation}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						是否涉密
					</view>
					<view class="cbox-2">
						{{whetherClassified}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						是否允许进口设备
					</view>
					<view class="cbox-2">
						{{importType}}
					</view>
				</view>
				
				<view class="content-box" v-if="isfisoreignTradeAgency">
					<view class="cbox-1">
						外贸代理机构
					</view>
					<view class="cbox-2">
						{{wmAgenciesId}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						预计采购时间
					</view>
					<view class="cbox-2">
						{{estimatedTime}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						购置必要性
					</view>
					<view class="cbox-2">
						{{acquisitionNecessity}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						交货地点
					</view>
					<view class="cbox-2">
						{{deliveryPlace}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						培训(天)
					</view>
					<view class="cbox-2">
						{{train}}
					</view>
				</view>
				
				<view class="content-box">
					<view class="cbox-1">
						售后响应时间(小时)
					</view>
					<view class="cbox-2">
						{{afterSalesResponseTime}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						发生故障上门服务时间(小时)
					</view>
					<view class="cbox-2">
						{{outOfServiceHours}}
					</view>
				</view>
				<view class="content-box">
					<view class="cbox-1">
						故障维修完毕时间(小时)
					</view>
					<view class="cbox-2">
						{{timeOfCompletionOfFaultRepair}}
					</view>
				</view>
			</view>
		</view>
	   <!-- <view class="purchase-module">
			<view class="purchase-title">
				出资财务项目
			</view>
	    	<view class="purchase-content">
	    		<view class="rbox-1" v-for="item in financeList " :key='item.id'>
	    			<view class="rbox-title">
	    			  {{item.financeProjectName}}
	    			</view>
					<view class="rbox-item">
                    <text>财务账号：</text>
					<text>{{item.financeAccount}}</text>
					</view>
					<view class="rbox-item">
					<text>项目负责人：</text>
					<text>{{item.realName}}</text>
					</view>
					<view class="rbox-item">
					<text>出资金额(元)：</text>
					<text>{{item.payMoney?item.payMoney.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','):'--'}}</text>
					</view>
	    		</view>
	    	</view>
	    </view> -->
	</view>

</template>

<script>
	
	import {getSimpleChilren,getBase1Info,getBase2Info,queryDictList,getProductList,getFinanceList} from '../../../api/service.js'
	export default{
		props:['cgId','status'],
		data(){
			return {
				flagePurchase:false,
				planStartTime:'',
				purContent:'',
				zxmuser:'',
				projectSurvey:'',
				projectcategory:'',
				subprojectname:'',
				projectname:'',
				realnamelist:'',
				purName:'',
				deptName:'',
				realname:'',
				phoneNumber:'',
				isGovPruchase:'',
				purchaseMoney:0,
				equipmentUsed:'',
				// 新添加字段
				whetherClassified: '',
				whetherTheInformation: '',
				importType: '',
				wmAgenciesId: '',
				train: '',
				estimatedTime: '',
				acquisitionNecessity: '',
				deliveryPlace: '',
				afterSalesResponseTime: '',
				outOfServiceHours: '',
				timeOfCompletionOfFaultRepair: '',
				isfisoreignTradeAgency: false,
				applyUserId_dictText:'',
				applyReason:'',
				cgTypeObj:{
					 'HW':"货物",
					 "FW":'服务',
					 "GC":'工程'
				},
				purWaysList:[
					{
					value:'1',
					text:'单一来源'
				},
				{
					value:'2',
					text:'自行采购'
				},{
					value:'3',
					text:'公开招标'
				},{
					value:'4',
					text:'邀请招标'
				},{
					value:'5',
					text:'竞争性谈判'
				},{
					value:'6',
					text:'竞争性磋商'
				},
				{
					value:'7',
					text:'集中采购'
				}
				],
				cgType:'',
				purCategory:'',
				purCategoryAttach:'',
				deliveryDate:'',
				guaranteePeriod:'',
				train:'',
				purWays:'',
				productList:[],
				financeList:[]
				
				
				
				
				
				
			}
		},
		created() {
			this.loadData();
			this.queryBase2Info();
			this.queryProductList();
			// this.queryFinanceList();
		},
		methods:{
			loadData(){
				getBase1Info({id:this.cgId}).then(res=>{
					 if (res.code == 200 || res.code == 0) {
					          this.queryChilren(res.result.subProjectId)
					    }
				})
			},
			// 获所属项目信息
			queryChilren(value){
				getSimpleChilren({ id: value }).then(res => {
				        var realnamelist = []
				        var zxmuserlist = []
				        if (res.result.jfdepartuser != '' && res.result.jfdepartuser && res.result.jfdepartuser.length > 0) {
				          for (let i = 0; i < res.result.jfdepartuser.length; i++) {
				            realnamelist.push(res.result.jfdepartuser[i].realname)
				          }
				        }
				        if (res.result.zxmuser != '' && res.result.zxmuser && res.result.zxmuser.length > 0) {
				          for (let i = 0; i < res.result.zxmuser.length; i++) {
				            zxmuserlist.push(res.result.zxmuser[i].realname)
				          }
				        }
				
				          this.zxmuser=zxmuserlist.join(','),
				          this.projectcategory=res.result.projectcategory,
				          this.subprojectname=res.result.subprojectname,
				          this.projectname=res.result.projectname,
				          this.realnamelist=realnamelist.join(',')
				          // this.c
				      })
			},
			// 申请信息
			queryBase2Info(){
				uni.showLoading({
				    title: '数据加载中'
				});
				getBase2Info({id:this.cgId}).then(res=>{
					uni.hideLoading()
					this.$nextTick(()=>{
						this.purName=res.result.purName;
						this.purchaseMoney=res.result.purchaseMoney?res.result.purchaseMoney.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ','):'--';
						this.deptName=res.result.deptName;
						this.realname=res.result.realname?res.result.realname:'';
						this.phoneNumber=res.result.phoneNumber;
						this.isGovPruchase=res.result.isGovPruchase;
						this.cgType=this.cgTypeObj[res.result.cgType]
						this.blackCode('category',res.result.purCategory).then(res=>{
							this.purCategory=res
						})
						this.purCategoryAttach=res.result.purCategoryAttach;
						this.deliveryDate=res.result.deliveryDate,
						this.guaranteePeriod=res.result.guaranteePeriod,
						this.train=res.result.train;
						// 新添加字段 2021-2-20
						this.applyReason = res.result.applyReason
						this.applyUserId_dictText = res.result.applyUserId_dictText
						this.timeOfCompletionOfFaultRepair=res.result.timeOfCompletionOfFaultRepair;
						this.outOfServiceHours=res.result.outOfServiceHours;
						this.afterSalesResponseTime=res.result.afterSalesResponseTime;
						this.deliveryPlace=res.result.deliveryPlace;
						this.acquisitionNecessity=res.result.acquisitionNecessity;
						this.estimatedTime=res.result.estimatedTime;
						this.wmAgenciesId=res.result.wmAgenciesId;
						this.train=res.result.train;
						this.importType=res.result.importType == '0' ? '否' : res.result.importType == '1' ? '是' : '';
						this.whetherClassified=res.result.whetherClassified == '0'? '否' : res.result.whetherClassified == '1' ? '是' : '';
						this.whetherTheInformation = res.result.whetherTheInformation == '0' ? '否' : res.result.whetherTheInformation == '1' ? '是' : '';
						if (res.result.importType == '1') {
							this.isfisoreignTradeAgency = true
						}
					// var temp = this.purWaysList.filter(item=>{
					// 		return item.value==res.result.purWays
					// 	})
					//  this.purWays =	temp.length>0?temp[0].text:'--'
					 this.blackCode('Purchase_method',res.result.purWays).then(res=>{
					 	this.purWays=res
					 })
					 this.blackCode('equip_used',res.result.equipmentUsed).then(res=>{
					 	this.equipmentUsed=res
					 })
					 if(res.result.cgType=='GC'){
						 this.flagePurchase=true;
						this.planStartTime=res.result.planStartTime;
						 this.blackCode('Purchase_content',res.result.purContent).then(res=>{
						 	this.purContent=res
						 })
						this.projectSurvey=res.result.projectSurvey 
					 }else{
						  this.flagePurchase=false
					 }
					
					   // equipmentUsed: res.result.equipmentUsed,
					})
				})
			},
			// code 的码装换
			blackCode(type,values){
				  var  tempDt=null;
				return new Promise(function(resolve,reject){
					queryDictList({id:type}).then(res=>{
						if(res.result){
							tempDt=res.result.filter(item=>{
								return item.value==values
							})
							resolve(tempDt.length>0?tempDt[0].text:'--')
						}else{
							reject('暂无数据')
						}
					})
				})
			},
			// 获取产品清单
			queryProductList(){
				getProductList({cgId:this.cgId}).then(res=>{
					if (res.result.records && res.result.records.length > 0) {
						this.productList=res.result.records;
						
					}else{
						this.productList=[];
					}
				})
			},
			queryFinanceList(){
				getFinanceList({cgId:this.cgId}).then(res=>{
					if (res.result && res.result.length > 0) {
						this.financeList=res.result;
						
					}else{
						this.financeList=[];
					}
				})
			}
		}
	}
</script>

<style lang="scss">
    @import "../../../colorui/purchase.scss"
	
</style>
